<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <title>企业号快捷开发平台</title>
    <script type="text/javascript" src="common/layui/layui.js"></script>
    <script type="text/javascript" src="common/jquery-3.2.0.min.js"></script>
    <script type="text/javascript" src="common/frame.js"></script>
    <link href="common/layui/css/layui.css" rel="stylesheet" media="all">
</head>
<body>
<style>
    html {
        height: 100%;
        margin: 0;
    }

    body {
        height: 100%;
        margin: 0;
    }

    .main {
        width: 100%;
        height: 100%;
    }

    .loading {
        width: 40%;
        height: 30px;
        line-height: 10px;;
        /*border: solid 1px #FD482C;*/
        margin: 0 auto;
        margin-top: 10%;
    }

    .layui-progress {
        margin-top: 17px;
    }
</style>

<div class="main">
    <div class="loading">
        正在进入...
        <div class="layui-progress layui-progress-mid" lay-showpercent="true" lay-filter="demo">
            <div class="layui-progress-bar layui-bg-green" lay-percent="0%"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use(['layer', 'element'], function () {
        layer.msg('欢迎...');
        var element = layui.element();
        element.init();
        layui.element().progress('demo', '50%');
        var obj = {
            //时间
            t: 0,
            //是否暂停
            s: 0,
            //随机进度
            r: Math.floor(Math.random() * 100),
            timer: function () {
                var self = this;
                this.t += 1;
                if (this.t <= 100 && this.s == 0) {
                    this.element();
                    setTimeout(function () {
                        self.timer();
                    }, 100);
                }
                if (this.t == (this.r > 80 ? 80 : this.r)) {
                    this.s = 1;//暂停
                }
            },
            //执行动画
            element: function () {
                this.t = this.t <= 100 ? this.t : 100;
                element.progress('demo', (this.t) + '%');
            },
            //立即结束
            finish: function () {
                this.t = 100;
                this.s = 2;
                this.element();
            },
            //按百分比前进
            forward: function (t) {
                this.t += t;
                this.element();
            }
        };
        obj.timer();
        //登录鉴权
        http.get('/system/api/auth', '', function (data) {
            obj.forward(10);
            if (data.data.result == 1) {
                obj.finish();
                //进入管理首页
                setTimeout(function () {
                    location.href = '/manager/';
                }, 400);
            } else {
                //进入授权流程
                location.href = data.data.authUrl;
            }
        })
    });
</script>

</body>
</html>